package com.ruoyi.aitymyy.api;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.aitcommon.anotation.ApiLog;
import com.ruoyi.aitcommon.utils.JSONResult;
import com.ruoyi.aitcommon.utils.WebServiceUtils;
import com.ruoyi.aitymyy.config.InterConfig;

/**
 * 易明U8C的OPENAPI
 * @author Administrator
 */
@RestController
@RequestMapping("/ait/ymyy/erp")
public class YmyyAPI {
	@ApiLog("U8C hello 接口")
	@PostMapping("/hello")
	public JSONObject hello(@RequestBody String jsonstr) {
		try {
//			注意：该地址不能有 ？wdsl 后缀
			String result = WebServiceUtils.invokeRemote(InterConfig.ws, "hello", "");
            return JSONObject.parseObject(result);
		}catch(Exception ex) {
			return JSONResult.error(ex.getMessage());
		}
	}
	
	@ApiLog("U8C通用查询接口")
	@PostMapping("/DBCommonQuery")
	public JSONObject DBCommonQuery(@RequestBody String jsonstr) {
		try {
            String result = WebServiceUtils.invokeRemote(InterConfig.ws, "DBCommonQuery", jsonstr);
            return JSONObject.parseObject(result);
		}catch(Exception ex) {
			ex.printStackTrace();
			return JSONResult.error(ex.getMessage());
		}
	}
	
	@ApiLog("U8C自定义档案写入接口")
	@PostMapping("/defdocSave")
	public JSONObject defdocSave(@RequestBody String jsonstr) {
		try {
            String result = WebServiceUtils.invokeRemote(InterConfig.ws, "defdocSave", jsonstr);
            return JSONObject.parseObject(result);
		}catch(Exception ex) {
			ex.printStackTrace();
			return JSONResult.error(ex.getMessage());
		}
	}
	
	@ApiLog("U8C供应商档案写入接口")
	@PostMapping("/cubasdocSave")
	public JSONObject cubasdocSave(@RequestBody String jsonstr) {
		try {
            String result = WebServiceUtils.invokeRemote(InterConfig.ws, "cubasdocSave", jsonstr);
			return JSONObject.parseObject(result);
		}catch(Exception ex) {
			return JSONResult.error(ex.getMessage());
		}
	}
	
	@ApiLog("U8C供应商地址写入接口")
	@PostMapping("/custaddrSave")
	public JSONObject custaddrSave(@RequestBody String jsonstr) {
		try {
            String result = WebServiceUtils.invokeRemote(InterConfig.ws, "custaddrSave", jsonstr);
            return JSONObject.parseObject(result);
		}catch(Exception ex) {
			return JSONResult.error(ex.getMessage());
		}
	}
}
